#{extends 'master.html' /}
#{set 'moreStyles'}
<link type="text/css" rel="stylesheet" href="@{'/public/javascripts/plugins/jHtml/style/jHtmlArea.css'}"/>
#{/set}
#{set 'moreScripts'}

<script type="text/javascript" src="@{'/public/javascripts/plugins/jHtml/jHtmlArea-0.7.0.js'}"></script>
<script type="text/javascript">
    $("textarea").htmlarea(
        {
            css:"@{'/public/javascripts/plugins/jHtml/style/jhtml.css'}"
        }
    );
</script>
#{/set}
<a href="${params.returnUrl}">Назад</a>
<div class="page_part">
    <div class="form">
        <form method="POST" action="@{ProductAdmin.postEditForm()}">
            <fieldset>
                <input type="hidden" value="${params.returnUrl}" name="returnUrl">
                <input type="hidden" value="${product.id}" name="p.id" />
                <div>
                    <label for="title">Название</label>
                    <input type="text" id="title" name="p.title" value="${product.title}"/>
                </div>
                <div>
                    <label for="shortDescription">Краткое описание</label>
                    <textarea rows="5" cols="20" id="shortDescription"
                              name="p.shortDescription">${product.shortDescription}</textarea>
                </div>
                <div>
                    <label for="description">Описание</label>
                    <textarea rows="10" cols="20" id="description"
                              name="p.description">${product.description}</textarea>
                </div>
                <div>
                    <label for="price">Цена</label>
                    <input type="text" id="price" name="p.price" value="${product.price}"/>
                </div>
                <input type="submit" value="Сохранить" />
            </fieldset>
        </form>
        <form action="@{ProductAdmin.addImage(product.id, params.returnUrl)}" method="POST" enctype="multipart/form-data">
            <input type="file" name="image" />
            <input type="submit" value="Добавить фото" />
        </form>
        #{list items:product.images, as:'image'}
            <div class="editable-image">
            <img src="@{Image.get(image.id, "product", 200, 149, false)}" alt="" />
            <form action="@{ProductAdmin.deleteImage(product.id, image.id, params.returnUrl)}" method="POST">
                  <input type="submit" value="Удалить" />
            </form>
            </div>
        #{/list}
    </div>
</div>